package scjp.preparation.threads;

class InfiniteWaitThread extends Thread {
	static boolean okayToRun = false;

	synchronized public void run() {
		while (!okayToRun) {
			try {
				// note the call to wait without any timeout value
				// so it waits forever for some thread to notify it
				wait(1000);
			} catch (InterruptedException ie) {
				// its okay to ignore this exception since we're not
				// interrupting exceptions in this code
				ie.printStackTrace();
			}
		}
	}

}

public class WaitingThreadState {
	public static void main(String[] s) throws InterruptedException {
		InfiniteWaitThread t = new InfiniteWaitThread();
		t.start();
		System.out.println(t.getName() + ": I'm in state " + t.getState());
//		t.okayToRun = true;
		for(Thread.State state : Thread.State.values()){
			System.out.println(state);
			}
	}
}